% t = reverbDuration(impResp, Fs)
% Recibe impResp con la respuesta al impulso de la room

function t = reverbDuration(impResp, Fs)
    n = length(impResp);
    E = norm(impResp,2);    % Energy of the signal
    t = 0;
    for k=1:10:n
        Ek = sum(norm(impResp(1:k),2)); % Partial sum of the signal energy
        if ( Ek > 0.8*E )
            t = k/Fs;
            break;
        end
    end
end

%Refs:
%http://www.voxengo.com/impulses/
%http://www.emes.de/pageseng/products/Impulsresponse/eimpulse.htm
